package com.coocaa.app.lib.cleaner.scanner.scannerother;

/**
 * Created by Eric on 2017/4/14.
 * <p>
 * public class Other_Web_Scan extends OtherWayScan{
 * private Context mContext = null;
 * <p>
 * public Other_Web_Scan(Context mContext) {
 * this.mContext = mContext;
 * }
 *
 * @Override public OtherData getData() {
 * //        String path = getCleanPathFromWeb(mContext,"http://tc.skysrt.com/appstore/appstorev3/");
 * //        path = "/data/data/com.um_abc.umtest_abc";
 * //        OtherData oD = new OtherData();
 * //        oD.list.add(path);
 * //        oD.length = FileUtils.getFileSize(path);
 * //        return oD;
 * return null;
 * }
 * <p>
 * public static String getCleanPathFromWeb (Context context, String server) {
 * String httpUrl = server + "getJsonString.html";
 * Log.d("server", "getJsonFromWeb  httpUrl:" + httpUrl);
 * String strResult = "";
 * // HttpGet连接对象
 * HttpGet httpRequest = new HttpGet(httpUrl);
 * Map<String,String> header = getHeaders(context);
 * for(String key:header.keySet()) {
 * httpRequest.addHeader(key,header.get(key));
 * }
 * try{
 * HttpClient httpclient =  new DefaultHttpClient();
 * HttpResponse httpResponse = httpclient.execute(httpRequest);
 * <p>
 * int statCode = httpResponse.getStatusLine().getStatusCode();
 * // 请求成功
 * if (statCode == HttpStatus.SC_OK) {
 * // 取得返回的字符串
 * strResult = EntityUtils.toString(httpResponse.getEntity());
 * } else {
 * Log.d("server", "HttpClient请求" + httpUrl + "出错，错误代码:" + statCode);
 * }
 * }catch(Exception e){
 * e.printStackTrace();
 * }finally{
 * //释放http连接
 * //            httpRequest.releaseConnection();
 * }
 * Log.d("server", "getJsonFromWeb  strResult:" + strResult);
 * return strResult;
 * }
 * <p>
 * private static final Map<String, String> DEFAULT_HEADERS = new HashMap<String, String>();
 * <p>
 * private static Map getHeaders(Context context) {
 * //        if (DEFAULT_HEADERS.size() == 0) {
 * //            DEFAULT_HEADERS.put("Accept-Encoding", "gzip");
 * ////                                try {
 * ////                                    DEFAULT_HEADERS.put("cUDID", XServiceManager.getLiteCCC().getDeviceActiveID());
 * ////                                } catch (Exception e) {
 * //            DEFAULT_HEADERS.put("cUDID", "");
 * ////                                }
 * //            String mac = MacUtils.getMAC(context);
 * //            DEFAULT_HEADERS.put("MAC", mac);
 * ////                                try {
 * ////                                    DEFAULT_HEADERS.put("cFMode", XServiceManager.getLiteCCC().getFMode());
 * ////                                } catch (Exception e) {
 * //            DEFAULT_HEADERS.put("cFMode", "Default");
 * ////                                }
 * //            CoocaaSystemUtils.DeviceModeMidType type = CoocaaSystemUtils.getDeviceModeMidType();
 * //            String cModel = type.skytype;  //后台是机型，但build.prop里面是skytype表示机型
 * //            String cChip = type.skymodel;  //后台是机芯，但build.skymodel表示机芯
 * //            DEFAULT_HEADERS.put("cModel", cModel);
 * //            DEFAULT_HEADERS.put("cChip", cChip);
 * //            String size = CoocaaSystemUtils.getDeviceSize();
 * //            DEFAULT_HEADERS.put("cSize", size);
 * //            String cResolution = CoocaaSystemUtils.getDevicePix(context);
 * //            DEFAULT_HEADERS.put("cResolution", cResolution);
 * //            String coocaaVersion = "";
 * //            try {
 * //                coocaaVersion = CoocaaSystemUtils.getCoocaaVersionString();
 * //            } catch (Exception e) {
 * //                e.printStackTrace();
 * //            }
 * //            DEFAULT_HEADERS.put("cTcVersion", coocaaVersion);
 * //            try {
 * //                DEFAULT_HEADERS.put("cPattern", CoocaaSystemUtils.getPattern());
 * //            } catch (Exception e) {
 * //                DEFAULT_HEADERS.put("cPattern", "normal");
 * //            }
 * //            DEFAULT_HEADERS.put("aSdk", String.valueOf(android.os.Build.VERSION.SDK_INT));
 * //
 * ////                                try {
 * ////                                    DEFAULT_HEADERS.put("cUserInfo", XServiceManager.getLiteCCC().getAccoutInfo());
 * ////                                } catch (Exception e) {
 * //            DEFAULT_HEADERS.put("cUserInfo", "");
 * ////                                }
 * //            Locale locale = Locale.getDefault();//CoocaaApplication.getContext().getResources().getConfiguration().locale;
 * //            DEFAULT_HEADERS.put("language", locale.getLanguage());
 * //            DEFAULT_HEADERS.put("area", locale.getCountry());
 * //            DEFAULT_HEADERS.put("memory", CoocaaSystemUtils.byte2MB(CoocaaSystemUtils.getmem_TOLAL() * 1000, false));
 * //            LogUtils.d("header","mac:"+mac);
 * //            LogUtils.d("header","cModel:"+cModel);
 * //            LogUtils.d("header","cChip:"+cChip);
 * //            LogUtils.d("header","size:"+size);
 * //            LogUtils.d("header","cResolution:"+cResolution);
 * //            LogUtils.d("header","coocaaVersion:"+coocaaVersion);
 * //            LogUtils.d("header","CoocaaSystemUtils.getPattern():"+CoocaaSystemUtils.getPattern());
 * //            LogUtils.d("header","sdk:"+String.valueOf(android.os.Build.VERSION.SDK_INT));
 * //            LogUtils.d("header","locale.getLanguage():"+locale.getLanguage());
 * //            LogUtils.d("header","locale.getCountry():"+locale.getCountry());
 * //            LogUtils.d("header","memory:"+CoocaaSystemUtils.byte2MB(CoocaaSystemUtils.getmem_TOLAL() * 1000, false));
 * //        }
 * return DEFAULT_HEADERS;
 * }
 * <p>
 * }
 */
/**
 public class Other_Web_Scan extends OtherWayScan{
 private Context mContext = null;

 public Other_Web_Scan(Context mContext) {
 this.mContext = mContext;
 }

 @Override public OtherData getData() {
 //        String path = getCleanPathFromWeb(mContext,"http://tc.skysrt.com/appstore/appstorev3/");
 //        path = "/data/data/com.um_abc.umtest_abc";
 //        OtherData oD = new OtherData();
 //        oD.list.add(path);
 //        oD.length = FileUtils.getFileSize(path);
 //        return oD;
 return null;
 }

 public static String getCleanPathFromWeb (Context context, String server) {
 String httpUrl = server + "getJsonString.html";
 Log.d("server", "getJsonFromWeb  httpUrl:" + httpUrl);
 String strResult = "";
 // HttpGet连接对象
 HttpGet httpRequest = new HttpGet(httpUrl);
 Map<String,String> header = getHeaders(context);
 for(String key:header.keySet()) {
 httpRequest.addHeader(key,header.get(key));
 }
 try{
 HttpClient httpclient =  new DefaultHttpClient();
 HttpResponse httpResponse = httpclient.execute(httpRequest);

 int statCode = httpResponse.getStatusLine().getStatusCode();
 // 请求成功
 if (statCode == HttpStatus.SC_OK) {
 // 取得返回的字符串
 strResult = EntityUtils.toString(httpResponse.getEntity());
 } else {
 Log.d("server", "HttpClient请求" + httpUrl + "出错，错误代码:" + statCode);
 }
 }catch(Exception e){
 e.printStackTrace();
 }finally{
 //释放http连接
 //            httpRequest.releaseConnection();
 }
 Log.d("server", "getJsonFromWeb  strResult:" + strResult);
 return strResult;
 }

 private static final Map<String, String> DEFAULT_HEADERS = new HashMap<String, String>();

 private static Map getHeaders(Context context) {
 //        if (DEFAULT_HEADERS.size() == 0) {
 //            DEFAULT_HEADERS.put("Accept-Encoding", "gzip");
 ////                                try {
 ////                                    DEFAULT_HEADERS.put("cUDID", XServiceManager.getLiteCCC().getDeviceActiveID());
 ////                                } catch (Exception e) {
 //            DEFAULT_HEADERS.put("cUDID", "");
 ////                                }
 //            String mac = MacUtils.getMAC(context);
 //            DEFAULT_HEADERS.put("MAC", mac);
 ////                                try {
 ////                                    DEFAULT_HEADERS.put("cFMode", XServiceManager.getLiteCCC().getFMode());
 ////                                } catch (Exception e) {
 //            DEFAULT_HEADERS.put("cFMode", "Default");
 ////                                }
 //            CoocaaSystemUtils.DeviceModeMidType type = CoocaaSystemUtils.getDeviceModeMidType();
 //            String cModel = type.skytype;  //后台是机型，但build.prop里面是skytype表示机型
 //            String cChip = type.skymodel;  //后台是机芯，但build.skymodel表示机芯
 //            DEFAULT_HEADERS.put("cModel", cModel);
 //            DEFAULT_HEADERS.put("cChip", cChip);
 //            String size = CoocaaSystemUtils.getDeviceSize();
 //            DEFAULT_HEADERS.put("cSize", size);
 //            String cResolution = CoocaaSystemUtils.getDevicePix(context);
 //            DEFAULT_HEADERS.put("cResolution", cResolution);
 //            String coocaaVersion = "";
 //            try {
 //                coocaaVersion = CoocaaSystemUtils.getCoocaaVersionString();
 //            } catch (Exception e) {
 //                e.printStackTrace();
 //            }
 //            DEFAULT_HEADERS.put("cTcVersion", coocaaVersion);
 //            try {
 //                DEFAULT_HEADERS.put("cPattern", CoocaaSystemUtils.getPattern());
 //            } catch (Exception e) {
 //                DEFAULT_HEADERS.put("cPattern", "normal");
 //            }
 //            DEFAULT_HEADERS.put("aSdk", String.valueOf(android.os.Build.VERSION.SDK_INT));
 //
 ////                                try {
 ////                                    DEFAULT_HEADERS.put("cUserInfo", XServiceManager.getLiteCCC().getAccoutInfo());
 ////                                } catch (Exception e) {
 //            DEFAULT_HEADERS.put("cUserInfo", "");
 ////                                }
 //            Locale locale = Locale.getDefault();//CoocaaApplication.getContext().getResources().getConfiguration().locale;
 //            DEFAULT_HEADERS.put("language", locale.getLanguage());
 //            DEFAULT_HEADERS.put("area", locale.getCountry());
 //            DEFAULT_HEADERS.put("memory", CoocaaSystemUtils.byte2MB(CoocaaSystemUtils.getmem_TOLAL() * 1000, false));
 //            LogUtils.d("header","mac:"+mac);
 //            LogUtils.d("header","cModel:"+cModel);
 //            LogUtils.d("header","cChip:"+cChip);
 //            LogUtils.d("header","size:"+size);
 //            LogUtils.d("header","cResolution:"+cResolution);
 //            LogUtils.d("header","coocaaVersion:"+coocaaVersion);
 //            LogUtils.d("header","CoocaaSystemUtils.getPattern():"+CoocaaSystemUtils.getPattern());
 //            LogUtils.d("header","sdk:"+String.valueOf(android.os.Build.VERSION.SDK_INT));
 //            LogUtils.d("header","locale.getLanguage():"+locale.getLanguage());
 //            LogUtils.d("header","locale.getCountry():"+locale.getCountry());
 //            LogUtils.d("header","memory:"+CoocaaSystemUtils.byte2MB(CoocaaSystemUtils.getmem_TOLAL() * 1000, false));
 //        }
 return DEFAULT_HEADERS;
 }

 }*/